<template>
    <img :src="src" v-bind="$attrs" @error="handleImageError" :style="{ objectFit: objectFit }" />
</template>

<script setup>

// 参数声明
const props = defineProps({
    src: {
        type: String,
        required: true
    },

    objectFit: {
        type: String,
        default: "cover"
    }
})

// 错误
const handleImageError = (event) => {
    event.target.src = "/fail.jpg";
}

</script>